package com.example.service;

import com.example.entity.Clockcalendar;
import com.example.entity.Learningrange;
import com.example.mapper.ClockcalendarMapper;
import com.example.mapper.LearningrangeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
用户学习范围业务处理
 */
@Service
public class LearningrangeService {

    @Resource
    private LearningrangeMapper learningrangeMapper;

    public void add(Learningrange learningrange) {
        learningrangeMapper.insert(learningrange);
    }

    public void deleteById(Integer id) {
        learningrangeMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Learningrange learningrange) {
        learningrangeMapper.updateById(learningrange);
    }

    public Learningrange selectById(Integer id) {
        return learningrangeMapper.selectById(id);
    }

    public List<Learningrange> selectAll(Learningrange learningrange) {
        return learningrangeMapper.selectAll(learningrange);
    }

    public PageInfo<Learningrange> selectPage(Learningrange learningrange, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Learningrange> learningrangeList = learningrangeMapper.selectAll(learningrange);
        return PageInfo.of(learningrangeList);
    }

    public Learningrange selectByUid(Integer uid) {
        return learningrangeMapper.selectByUid(uid);
    }

}
